<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#Setup Queries
include 'config.php';
$conn = mysql_connect($databasehost, $databaseuser, $databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());

class SetupQuery
{
	public function structureQuery($websiteurl, $websitename)
	{
		$articlequery="CREATE TABLE IF NOT EXISTS articles (
  id smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  author varchar(20) NOT NULL,
  title varchar(225) NOT NULL,
  summary varchar(65) NOT NULL,
  content mediumtext NOT NULL,
  keywords text NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; ";


$commentquery = "CREATE TABLE IF NOT EXISTS comments (
  id int(5) NOT NULL,
  pid int(5) NOT NULL,
  `type` varchar(1) NOT NULL,
  poster text NOT NULL,
  email text NOT NULL,
  `date` datetime NOT NULL,
  commenttext text NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";


$pagequery = "CREATE TABLE IF NOT EXISTS pages (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(20) NOT NULL,
  content mediumtext NOT NULL,
  keywords text NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;";


$settingquery =  "CREATE TABLE IF NOT EXISTS settings (
  setting text NOT NULL,
  `value` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";

$settingquery2 = "INSERT INTO settings (setting, `value`) VALUES
('WebsiteURL', '". $websiteurl . "'),
('WebsiteName', '" . $websitename . "'),
('Style', 'default'),
('VideoGalleryEnabled', '1');";

$userquery = "CREATE TABLE IF NOT EXISTS users (
  id int(5) unsigned NOT NULL AUTO_INCREMENT,
  username text NOT NULL,
  `password` text NOT NULL,
  email text NOT NULL,
  rank int(1) NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";


$videoquery = "CREATE TABLE IF NOT EXISTS videos (
  id smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  author varchar(20) NOT NULL,
  title varchar(225) NOT NULL,
  url text NOT NULL,
  `text` mediumtext NOT NULL,
  keywords text NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";


$visitorquery="CREATE TABLE IF NOT EXISTS visitors (
  IP text NOT NULL,
  `Date` datetime NOT NULL,
  `Page` text NOT NULL,
  Browser text NOT NULL,
  Platform text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$rst1 = mysql_query($articlequery) or die(mysql_error());
$rst2 = mysql_query($commentquery) or die(mysql_error());
$rst3 = mysql_query($pagequery) or die(mysql_error());
$rst4 = mysql_query($settingquery) or die(mysql_error());
$rst42 = mysql_query($settingquery2) or die(mysql_error());
$rst5 = mysql_query($userquery) or die(mysql_error());
$rst6 = mysql_query($videoquery) or die(mysql_error());
$rst7 = mysql_query($visitorquery) or die(mysql_error());


	}

}
?>